<?php
class Catalog_IndexController extends Zend_Controller_Action {
	
	public function init() {
		$this->model = new Catalog_Model_Tree();
	}
	
	public function listAction() {
		$alias = $this->_helper->checkParam('alias',true,'StripTags','NotEmpty');

		Zen_Style::add ( Zen_Theme::_('/css/catalog_filter.css'));
		Zen_Script::add (Zen_Theme::_('/js/jquery-ui-1.8.11.custom.min.js'));
		Zen_Script::add (Zen_Theme::_('/js/jquery.spinbox.js'));
		Zen_Script::add (Zen_Theme::_('/js/catalog_filter.js'));
		
		if($alias=='divany'||$alias=='divany-uglovie'){
			$this->view->filter = true;
		}
		
		$folder = $this->model->getFolderByAlias($alias);
		if (! $folder)
			return false; 
		$items = $this->model->getItemListByAlias($alias);
		if (! $items)
			return false;
		$this->view->folder = $folder;
		$this->view->items = $items;	

	}
	
	public function itemAction(){
		Zen_Style::add ( Zen_Theme::_('/css/catalog_one.css'));
		Zen_Script::add('http://userapi.com/js/api/openapi.js?26');
		Zen_Style::add ( Zen_Theme::_('/res/cloud-zoom/cloud-zoom.css' ));
		Zen_Script::add ( Zen_Theme::_('/res/cloud-zoom/cloud-zoom.1.0.2.js' ));
		
		$wares = $this->_helper->checkParam('wares',true,'StripTags','NotEmpty');
		$res = $this->model->getItemByAlias($wares);
		$this->view->item=$res;
	}

}
